package router

import (
	worktable "gitee.com/xuesongtao/collect/app/service"
	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gf/os/gcron"
	"github.com/gogf/gf/os/glog"
)

func RegisterCron() {
	glog.Info("register cron")

	// 监控
	gcron.AddSingleton(g.Cfg().GetString("collect.cronMonitor"), warnLog("CronMonitor", worktable.CronMonitor))

	// 定时添加日志
	// gcron.AddSingleton(g.Cfg().GetString("collect.cronAddLogPath"), warnLog("AddLogPath", worktable.AddLogPath))

	glog.Info("register success")
}

func warnLog(name string, f func()) func() {
	glog.Infof("start %q ....", name)
	defer glog.Infof("end %q", name)
	return f
}
